package com.leanin.form.contoller;

import com.leanin.form.model.request.FormQueryDTO;
import com.leanin.form.model.request.SatisfyFormDTO;
import com.leanin.form.model.response.CommonResponseResult;
import com.leanin.form.model.response.QueryResponseResult;
import com.leanin.form.model.response.ResponseResult;
import com.leanin.form.service.SatisfyFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author CPJ.
 * @date 2019/6/14.
 * @time 15:15.
 */
@RestController
@RequestMapping("/satisfyForm")
public class SatisfyFormController {

    @Autowired
    private SatisfyFormService satisfyFormService;

    /**
     * 添加满意度表单
     * @param satisfyFormDTO
     * @return
     */
    @PostMapping("/addSatisfyForm")
    public ResponseResult addSatisfyForm(@RequestBody SatisfyFormDTO satisfyFormDTO){
        return satisfyFormService.addSatisfyForm(satisfyFormDTO);
    }

    /**
     * 修改满意度表单
     * @param satisfyFormDTO
     * @return
     */
    @PutMapping("/updateSatisfyForm")
    public ResponseResult updateSatisfyForm(@RequestBody SatisfyFormDTO satisfyFormDTO){
        return satisfyFormService.updateSatisfyForm(satisfyFormDTO);
    }

    /**
     * 条件查询满意度表单
     * @param formQueryDTO
     * @return
     */
    @PostMapping("/findByParam")
    public QueryResponseResult findByParam(@RequestBody FormQueryDTO formQueryDTO){
        return satisfyFormService.findByParam(formQueryDTO);
    }

    /**
     * 根据id 查询表单内容
     * @param formId
     * @return
     */
    @GetMapping("/findById")
    public CommonResponseResult findById(@RequestParam("formId") Long formId){
        return satisfyFormService.findById(formId);
    }

    /**
     * 添加下载次数
     * @param formId
     * @return
     */
    @GetMapping("/addDownLoadCount")
    public ResponseResult addDownLoadCount(@RequestParam("formId")Long formId){
        return satisfyFormService.addDownLoadCount(formId);
    }

    /**
     * 删除表单
     * @param formId
     * @return
     */
    @DeleteMapping("/deleteForm")
    public ResponseResult deleteForm(@RequestParam("formId") Long formId){
        return satisfyFormService.deleteForm(formId);
    }
}
